package com.nova.scenic.projectlibs.util.graphics;

import com.nova.scenic.projectlibs.util.debug.ToastAlertUtil;

import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.Gravity;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageView;

public class DrawableUtil {

	
	public static void showDrawable(Context context, Drawable drawable) {

		if (drawable == null) {
			ToastAlertUtil.alertToast(context, new Handler(), System.currentTimeMillis(), "Error drawable is null");
			return;
		}

		LayoutParams params = new LayoutParams();
		params.format = PixelFormat.RGBA_8888;
		params.width = LayoutParams.WRAP_CONTENT;
		params.height = LayoutParams.WRAP_CONTENT;
		// params.x = X;

		params.flags = LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_LAYOUT_IN_SCREEN | LayoutParams.FLAG_LAYOUT_NO_LIMITS;
		params.type = LayoutParams.TYPE_APPLICATION_PANEL;
		params.gravity = Gravity.TOP | Gravity.LEFT;
		;

		WindowManager mManager = null;
		if (mManager == null) {
			mManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		}
		ImageView img = new ImageView(context);
		img.setImageDrawable(drawable);
		mManager.addView(img, params);
	}

}
